package com.wlr.study.leetcode;

import java.util.concurrent.CountDownLatch;

/**
 * CountDownLatch
 *
 * @author lrwang
 * @version 1.0
 * @date 2021/9/14 23:56
 */
public class CountDown {
    private static CountDownLatch countDownLatch = new CountDownLatch(6);

    public static void main(String[] args) throws InterruptedException {
        for (int i = 1; i <= 6; i++) {
            new Thread(() -> {
                /**
                 * 函数体
                 */
                System.out.println(Thread.currentThread().getName() + "\t 国，被灭了");
                countDownLatch.countDown();
            }, CountryEnum.forEach_countryEnum(i).getRetMessage()).start();
        }
    }

    private static void countDownExample() throws InterruptedException {
        for (int i = 0; i < 6; i++) {
            new Thread(() -> {
                /**
                 * 函数体
                 */
                System.out.println(Thread.currentThread().getName() + "\t 上完自习，离开教室");
                countDownLatch.countDown();
            }, String.valueOf(i)).start();
        }
        countDownLatch.await();
        System.out.println(Thread.currentThread().getName() + "\t**********************班长走了，锁门");
    }
}
